package com.ooqiu.gaming.injector.modules;


import com.ooqiu.gaming.GamingApp;
import com.ooqiu.gaming.common.Constants;
import com.ooqiu.greendao.DaoMaster;
import com.ooqiu.greendao.DaoSession;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by Eenie on 2017/11/16.
 * Email: eeniework@gmail.com
 * Des:提供数据库存储相关实例
 */
@Module
public class DBModule {

    public static final String DB_NAME = Constants.DB_NAME;
    @Provides
    @Singleton
    DaoMaster.DevOpenHelper provideDevOpenHelper(GamingApp context) {
        return new DaoMaster.DevOpenHelper(context, DB_NAME);
    }


    @Provides
    @Singleton
    DaoMaster provideDaoMaster(DaoMaster.DevOpenHelper helper) {
        return new DaoMaster(helper.getWritableDatabase());
    }


    @Provides
    @Singleton
    DaoSession provideDaoSession(DaoMaster master) {
        return master.newSession();
    }



}
